# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models,api
from odoo.exceptions import ValidationError
import odoo.addons.decimal_precision as dp
import re

class mrp_production(models.Model):
    _inherit = 'mrp.production'


    @api.multi
    def mrp_set_move_raw_lots(self):
        for production in self:
            for move in production.move_raw_ids:
                move.create_lots()
                for lot in move.active_move_lot_ids:
                    plus = lot.quantity - lot.quantity_done
                    i = 0
                    while i < plus:
                        lot.do_plus()
                        i += 1
                    temp = re.split(r'\.', str(lot.quantity))
                    s = float('%s%s' % ('0.', temp[1].strip()))
                    if s > 0:
                        lot.quantity_done = lot.quantity_done + s -1

